package com.example.aggregatedemo.arrary.a05mySet;

public class Student_Tree implements Comparable<Student_Tree>{
    private String name;
    private Integer age;

    public Student_Tree(String z3, int i) {
        this.name=z3;
        this.age=i;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

//    @Override
//    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (!(o instanceof Student)) return false;
//        Student student = (Student) o;
//        return Objects.equals(getName(), student.getName()) && Objects.equals(getAge(), student.getAge());
//    }
//
//    @Override
//    public int hashCode() {
//        return Objects.hash(getName(), getAge());
//    }

    @Override
    public int compareTo(Student_Tree o) {
        //指定排序的规则
        //只看年龄
        //this表示要添加的元素
        //o，表示红黑树中已经有的元素
        //reusult是负数，新值存左边，为0表示已存在
        int result=this.getAge()-o.getAge();
        return result;
    }
}
